<admintpl file="header" />
</head>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li class="active"><a href="javascript:;">销售统计</a></li>
    </ul>
    <form class="well form-search" method="post" id="form1">
        <label for="store_id">总店列表</label>
        <select name="store_id" id="store_id">
            <option value="">请选择总店</option>
            <foreach name="storeList" item="s">
                <option value="{$s.store_id}" <if condition="$store_id eq $s['store_id']">selected</if>>{$s.store_name}</option>
            </foreach>
        </select>
        <label for="store_parent_id">分店列表</label>
        <select name="store_parent_id" id="store_parent_id">
            <option value="">请选择分店</option>
            <foreach name="store_parentList" item="p">
                <option value="{$p.store_id}" <if condition="$store_parent_id eq $p['store_id']">selected</if>>{$p.store_name}</option>
            </foreach>
        </select>
        <br/><label for="test16">开始时间</label>
        <input type="text" class="js-datetime" name="start_time" id="test16"  placeholder="点击选择开始时间" style="width: 180px;"  value="{$start_time}">
        <label for="test17">结束时间</label>
        <input type="text" class="js-datetime" name="end_time" id="test17" placeholder="点击选择结束时间" style="width: 180px;"  value="{$end_time}">
        <input type="submit" class="btn btn-primary" value="搜索" onclick="return index()"/>
        <a class="btn btn-danger" href="{:U('Cencs/ordership')}">清空</a>
        <input type="submit" class="btn btn-success" value="导出excel" onclick="return excel()"/>
        <div class="col-md-9" >
            <label>销售金额：</label>
             {$newArr.total.order_amount|default=0}
            <label>退款金额：</label>
             {$newArr.refund.order_amount|default=0}
            <label>销售总额统计：</label>
            已确认金额：{$newArr.totalSale.order_amount|default=0}  未确认金额：{$newArr.totalSaleStatus.order_amount|default=0}
            <label>退款总额 ：</label>
            {$newArr.totalReturn.order_amount|default=0}
        </div>
    </form>
    <if condition="$newArr.list neq ''">
        <table class="table table-hover table-bordered table-list">
            <thead>
            <tr>
                <th>用户名</th>
                <th>订单号</th>
                <th>商家名称</th>
                <th>商品名称</th>
                <th>商品单价</th>
                <th>商品税费</th>
                <th>规格</th>
                <th>折扣价</th>
                <th>订单折扣价</th>
                <th>合计金额</th>
                <th>订单状态</th>
                <th>下单时间</th>
                <th>归属店铺</th>
            </tr>
            </thead>
            <tbody>
            <volist name="newArr.list" id ="ord">
                <tr>
                    <td>{$ord.buyer_name}</td>
                    <td>{$ord.order_sn}</td>
                    <td>{$ord.seller_name}</td>
                    <td>{$ord.goods_name}</td>
                    <td>{$ord.price}</td>
                    <td>{$ord.tax_price}</td>
                    <td>{$ord.specification}</td>
                    <td>{$ord.discount}</td>
                    <td>{$ord.order_amount}</td>
                    <td>{$ord.goods_amount}</td>
                    <td>{$ord.status_value}</td>
                    <td>{$ord.add_time|date="Y-m-d H:i",###}</td>
                    <td>{$ord.store_name}</td>
                </tr>
            </volist>
            </tbody>
        </table>
    </if>
    <div class="pagination">{$newArr.page}</div>
    </form>
</div>
<script src="__PUBLIC__/js/common.js"></script>
<script src="__PUBLIC__/layer/layer.js"></script>
</body>
<script type="text/javascript">
    $(".btn-close").click(function () {
        window.parent.$('.bg-model').hide();
    })
    function index(){
        $("#form1").attr('action',"{:U('Order/index')}");
        return true;
    }
    function excel(){
        $("#form1").attr('action',"{:U('Order/excel')}");
        return true;
    }
</script>
<script type="text/javascript">
    function index(){
        $("#form1").attr('action',"{:U('Cencs/ordership')}");
        return true;
    }
    function excel(){
        $("#form1").attr('action',"{:U('Cencs/excelOrder')}");
        return true;
    }

    $("#store_id").change(function(){
        var store_id = $(this).val();
        var url = "{:U('Member/getStore')}";
        if(store_id != ''){
            var str = '<option value="">请选择分店</option>'
            $.post(url,{
                store_id:store_id
            },function(data){
                var res = JSON.parse(data);
                if(res.length > 0){
                    $.each(res,function(index,item){
                        str += "<option value='"+item.store_id+"'>"+item.store_name+"</option>";
                    })
                }
                $("#store_parent_id").html(str);
            })
        }
    })
</script>

</html>
